<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>商品管理管理</title>
	<meta name="decorator" content="default"/>
	<link rel="stylesheet" type="text/css" href="${ctxStatic}/ztree/css/demo.css">
	<link rel="stylesheet" type="text/css" href="${ctxStatic}/ztree/css/zTreeStyle/zTreeStyle.css">
	<script type="text/javascript" src="${ctxStatic}/ztree/js/jquery.ztree.all-3.5.js"></script>
	<script type="text/javascript" src="${ctxStatic}/ztree/js/jquery.ztree.core-3.5.js"></script>
	<link rel="stylesheet" type="text/css" href="${ctxStatic}/plupload/bootstrap.min.css">
	<script type="text/javascript" src="${ctxStatic}/plupload/plupload.full.min.js"></script>
	<script type="text/javascript" src="${ctxStatic}/ztree/js/jquery.ztree.excheck-3.5.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			$("#btnSubmit").click(function() {
				if ($("#catalogid").val() == "") {
					alert("请选择商品分类");
					return false;
				}
				$("#inputForm").submit();
			});
		});
		function tissueParameters() {
			$("#catalogid2").val($("#catalogid").val());
			$("#name2").val($("#name").val());
			$("#order2").val($("#order1").val());
			$("#introduce2").val($("#introduce").val());
			$("#code2").val($("#code").val());
			$("#brand2").val($("#brand").val());
			$("#nowprice2").val($("#nowprice").val());
			$("#stock2").val($("#stock").val());
			$("#score2").val($("#score").val());
			$("#maxpicture2").val($("#maxpicture").val());
			$("#images2").val($("#images").val());
			$("#producthtml2").val($("#producthtml").val());
			$("#detail2").val($("#detail").val());
		}
		function associate() {
			tissueParameters();
			if ($("#catalogid2").val() == "") {
				alert("请选择分类！");
				return false;
			}
			
			$("#tabFrm").attr("action","${ctx}/product/product/genProduct/gif");
			$("#tabFrm").submit();
		}
		
		function form() {
			tissueParameters();
			$("#tabFrm").attr("action","${ctx}/product/product/genProduct/form");
			$("#tabFrm").submit();
		}
		
		function parameter() {
			tissueParameters();
			$("#tabFrm").attr("action","${ctx}/product/product/genProduct/parameter");
			$("#tabFrm").submit();
		}
		function picture() {
			tissueParameters();
			$("#tabFrm").attr("action","${ctx}/product/product/genProduct/picture");
			$("#tabFrm").submit();
		}
		function detail() {
			tissueParameters();
			$("#tabFrm").attr("action","${ctx}/product/product/genProduct/detail");
			$("#tabFrm").submit();
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="#" onclick="form();">基本信息</a></li>
		<li ><a href="#" onclick="detail();">介绍</a></li>
		<li ><a href="#" onclick="picture();">商品图片</a></li>
		<li ><a href="#" onclick="parameter();">商品参数</a></li>
		<li ><a href="#" onclick="associate();">关联</a></li>
	</ul><br/>
	<form:form id="tabFrm" modelAttribute="genProduct" action="" method="post">
		<form:hidden path="id"/>
		<form:hidden path="catalogid" id="catalogid2"/>
		<form:hidden path="name" id="name2"/>
		<form:hidden path="introduce" id="introduce2"/>
		<form:hidden path="code" id="code2"/>
		<form:hidden path="brand" id="brand2"/>
		<form:hidden path="nowprice" id="nowprice2"/>
		<form:hidden path="stock" id="stock2"/>
		<form:hidden path="score" id="score2"/>
		<form:hidden path="maxpicture" id="maxpicture2"/>
		<form:hidden path="images" id="images2"/>
		<form:hidden path="associateStr" id="associateStr2"/>
		<form:hidden path="producthtml" id="producthtml2"/>
		<form:hidden path="detail" id="detail2"/>
		<form:hidden path="order1" id="order2"/>
	</form:form>
	<form:form id="inputForm" modelAttribute="genProduct" action="${ctx}/product/product/genProduct/save" method="post" class="form-horizontal" >
		<form:hidden path="id"/>
		<form:hidden path="associateStr"/>
		<form:hidden path="maxpicture" id="maxpicture"/>
		<form:hidden path="images" id="images"/>
		<form:hidden path="producthtml" id="producthtml"/>
		<form:hidden path="detail" id="detail"/>
		<input type="hidden" id="sizes" name="sizes" value="" />
		
		<sys:message content="${message}"/>	
		<div class="control-group">
			<label class="control-label">分类：</label>
			<div class="controls">
				<form:input path="catalogName" htmlEscape="false" maxlength="64" />
			</div>
		</div>	
		<div class="control-group">
			<label class="control-label">商品名称：</label>
			<div class="controls">
				<form:input path="name" id="name" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">简介：</label>
			<div class="controls">
				<form:textarea path="introduce" id="introduce" htmlEscape="false" maxlength="500" class="input-xlarge required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">货号：</label>
			<div class="controls">
				<form:input path="code" id="code" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">品牌：</label>
			<div class="controls">
				<form:input path="brand" id="brand" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">现价：</label>
			<div class="controls">
				<form:input path="nowprice" id="nowprice" htmlEscape="false" class="input-xlarge required"/>
				
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">库存：</label>
			<div class="controls">
				<form:input path="stock" id="stock"  htmlEscape="false" maxlength="11" class="input-xlarge required"/>
				
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">赠送积分：</label>
			<div class="controls">
				<form:input path="score"  id="score" htmlEscape="false" maxlength="11" class="input-xlarge required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">主图：</label>
			<div class="controls">
				<p id="ossfile"></p>
				<input type="button" value="选择文件"  id="browse" accept=".BMP,.JPG,.JPEG,PNG,GIF" class="color ci_width_90 zl_loading" />
				<input type="button" value="开始上传" id="start_upload" class="color ci_width_90 zl_loading" />
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="product:product:genProduct:edit">
				<input id="btnSubmit" class="btn btn-primary" type="button" value="保存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>